<template>
	<view class="content">
		<view class="main">
			<image id="img" src="http://minipos.posyun3721.com/image/login-img.png"></image>
			<text id="name">会员中心</text>
			<text id="title">申请获取您的头像、性别、手机号码的信息权限</text>
			<text >该小程序仅限已经注册了博雅城会员的用户登录使用</text>
		</view>
		<view class="but">
			<input id="refused" type="text" disabled="disabled" value="拒绝" @tap="Refused"></input>
			<button id="allow" @tap="getUserProfile" withCredentials="true">允许</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loginID: 0,
			}
		},
		onLoad() {
			var pages = getCurrentPages(); //当前页
			var beforePage = pages[pages.length - 2]; //上个页面
			this.$beforePage = "/" + beforePage.route + "?scene=" + beforePage.options.scene;

		},
		methods: {
			//拒绝
			Refused: function() {
				var id = uni.getStorageSync('FItemID');
				var url = uni.getStorageSync('PagePath');
				// uni.reLaunch({
				// 	url: this.$beforePage,
				// })
				wx.navigateBack({
					delta: 1
				})
				uni.setStorageSync('LoginID', 0) //缓存登
			},
			getUserProfile(e) {
				// 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
				uni.getUserProfile({
					desc: '获取用户个人信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
					success: (res) => {
						this.userInfo = res.userInfo;
						this.hasUserInfo = true;
						// uni.setStorageSync('shopCart', JSON.stringify(shopCart));
						uni.setStorageSync('userInfo', res.userInfo);
						uni.setStorageSync('MuserInfo', res.userInfo);
						// uni.reLaunch({
						// 	url: this.$beforePage,
						// })
						wx.navigateBack({
							delta: 1
						})
					}
				})
			},
		}
	}
</script>

<style>
	.content {
		width: 100%;
		height: auto;
	}

	.main {
		height: auto;
		padding: 60rpx 62rpx;
		border-top: 2rpx solid #F1F1F1;
	}

	#img {
		width: 132rpx;
		height: 132rpx;
		display: block;
		text-align: center;
		margin: 0 auto 20rpx auto;
	}

	#name {
		display: block;
		text-align: center;
		color: #191919;
		font-size: 28rpx;
		font-weight: bold;
		line-height: 38rpx;
		margin-bottom: 60rpx;
	}

	#title {
		display: block;
		color: #191919;
		font-size: 32rpx;
		font-weight: bold;
		line-height: 42rpx;
	}

	.but {
		width: 100%;
		height: 88rpx;
		position: fixed;
		bottom: 110rpx;
		display: flex;
		justify-content: space-around;
	}

	.but input {
		width: 254rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-size: 36rpx;
		text-align: center;
		border-radius: 12rpx;
	}

	#refused {
		background: #EFEEEC;
		color: #000;
	}

	#allow {
		width: 254rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-size: 36rpx;
		text-align: center;
		border-radius: 12rpx;
		background: #09C66A;
		color: #fff;
		margin: 0;
	}
</style>
